import Http from '@/axios';
import { PageQuery } from '@/model/common';
import { ${obj.classPrefix}Form, ${obj.classPrefix}Query } from '@/model/${obj.relativePath}';

export default class ${obj.classPrefix}Api {
    public static insert(form: ${obj.classPrefix}Form) {
        return Http.post(this.handleUrl('insert'), form);
    }

    public static update(form: ${obj.classPrefix}Form) {
        return Http.post(this.handleUrl('update'), form);
    }

    public static delete(id: string) {
        return Http.post(this.handleUrl('delete'), { id });
    }

    public static pageList(query: ${obj.classPrefix}Query, page?: PageQuery) {
        return Http.get(this.handleUrl('list/page'), Object.assign({}, query, page));
    }

    public static info(id: string) {
        return Http.get(this.handleUrl('info'), { id });
    }

    private static handleUrl(relativeUrl: string) {
        return '/api/${obj.requestRelativeUrl}/' + relativeUrl;
    }
}
